package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
@JsonIgnoreProperties(value = {"json"})
public class Daily extends BaseDomain{
    public static final int STATE_DRAFT = 0; // 草稿
    public static final int STATE_RELEASE = 1; // 发布
    public static final int STATE_DISABLE = -1; // 禁用

    //标题
    private String title;

    //图片
    private String coverUrl;

    //创建时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date releaseTime;

    //状态
    private Integer state=STATE_RELEASE;

    //发布时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createTime;

    //日报内容
    private DailyContent dailyContent;

    public String getJson() {
        HashMap<String, Object> map = new HashMap();
        map.put("id", id);
        map.put("title", title);
        map.put("coverUrl", coverUrl);
        map.put("state", state);
        map.put("dailyContent",dailyContent.getContent());
        map.put("dailyContentId",dailyContent.getId());
        return JSONUtils.toJSONString(map);
    }
}